package edu.guigu.networkdemo.network;

import okhttp3.Call;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

public class UserClient implements UserApi{

    private static final OkHttpClient okHttpClient = new OkHttpClient();
    private static UserClient userClient;

    private UserClient(){}

    public static UserClient getInstance(){
        if (userClient == null){
            userClient = new UserClient();
        }
        return userClient;
    }

    @Override
    public Call getUser(String url) {
        // 请求对象(默认是get请求)
        Request request = new Request.Builder()
                .url(url)
                .build();

//        RequestBody body = new FormBody();
//        body.
//        Request request = new Request.Builder()
//                .url("xxxx")
//                .post(body)
//                .build();
        // 返回这个一次call
        return okHttpClient.newCall(request);
    }

    @Override
    public Call getUserList(String url) {
        // 请求对象(默认是get请求)
        Request request = new Request.Builder()
                .url(url)
                .build();
        // 返回这个一次call
        return okHttpClient.newCall(request);
    }
}
